Skip to content

Conversation

@threepointone
Copy link
Contributor

Extract @cloudflare/ai-chat and @cloudflare/codemode into their own packages with comprehensive READMEs. Update agents README to remove chat-specific content and point to new packages. Fix documentation imports to reflect new package structure.

Maintains backward compatibility, no breaking changes.

Extract @cloudflare/ai-chat and @cloudflare/codemode into their own packages with comprehensive READMEs. Update agents README to remove chat-specific content and point to new packages. Fix documentation imports to reflect new package structure.

Maintains backward compatibility, no breaking changes.
@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2025

🦋 Changeset detected

Latest commit: f0db0c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@cloudflare/codemode Patch
@cloudflare/ai-chat Patch
agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@claude
Copy link

claude bot commented Dec 29, 2025

Claude Code Review

Issues Found

1. Runtime console.log side effects in production code

The re-export files have deprecation warnings via console.log that execute on import:

  • packages/agents/src/ai-chat-agent.ts:3-5
  • packages/agents/src/ai-react.tsx:3-5
  • packages/agents/src/codemode/ai.ts:3-5
  • packages/agents/src/ai-types.ts:14-16

Problem: These console.log statements run every time the module is imported, even in production. This adds unnecessary overhead and pollutes logs.

Recommendation: Use build-time deprecation warnings instead:

  • Add @deprecated JSDoc tags
  • Use TypeScript's deprecation support
  • Or move to build-time warnings/errors

Example:

/**
 * @deprecated Use @cloudflare/ai-chat instead. Will be removed in v1.0.0
 */
export * from "@cloudflare/ai-chat";

2. Missing peerDependency metadata

packages/agents/package.json:50-60 adds new peer dependencies but doesn't mark them as optional:

"@cloudflare/ai-chat": "^0.0.1",
"@cloudflare/codemode": "^0.0.1",

Problem: These should be in peerDependenciesMeta as optional since the old paths still work via re-exports. Users not explicitly using these packages shouldn't need them installed.

3. Type-only export missing from ai-types.ts

packages/agents/src/ai-types.ts:8 exports both types and values:

export type { IncomingMessage, OutgoingMessage };
export const MessageType = { ...AiChatMessageType, ...AgentsMessageType };

The MessageType merge combines enums from two sources. Verify this doesn't cause enum key collisions at runtime.


Summary

Good refactoring overall - clean package separation and backward compatibility maintained. Address the console.log side effects and peer dependency metadata before merging.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 29, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@756

commit: f0db0c7

agents-git-bot bot pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Dec 29, 2025
Update documentation to reflect the package reorganization where AI chat
functionality has been extracted into @cloudflare/ai-chat package:

- Update import paths from agents/ai-chat-agent to @cloudflare/ai-chat
- Update import paths from agents/ai-react to @cloudflare/ai-chat/react
- Affects human-in-the-loop guide and agents API reference

Related to cloudflare/agents#756

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
agents-git-bot bot pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Dec 29, 2025
… packages

Sync documentation changes from cloudflare/agents PR #756:
- Update import paths from agents/* to @cloudflare/ai-chat/* and @cloudflare/codemode/*
- Add comprehensive documentation for @cloudflare/ai-chat package
- Add comprehensive documentation for @cloudflare/codemode package
- Update all code examples to reflect new package structure

This reflects the splitting of ai-chat and codemode into separate packages
while maintaining backward compatibility.

Source PR: cloudflare/agents#756
@threepointone threepointone merged commit 0c4275f into main Dec 29, 2025
5 checks passed
@threepointone threepointone deleted the chat-package branch December 29, 2025 16:04
@github-actions github-actions bot mentioned this pull request Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant